package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.css.CSSDeclaration;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.CustomActionBar;
import com.huawei.appmarket.framework.widget.RenderImageView;
import com.huawei.appmarket.framework.widget.RenderImageView.b;
import com.huawei.appmarket.service.store.awk.bean.ImmersiveHeadImgCardBean;
import o.azb;
import o.cgz;
import o.Logger;
import o.epv;
import o.eqx;
import o.eqz;
import o.erq;
import o.ewm.d;
import o.ewm.j;

public class ImmersiveHeadImgCard extends BaseDistCard implements eqz, b {
    private TextView ʻ;
    private TextView ʼ;
    private String ʽ;
    private boolean ˊॱ = false;
    private RenderImageView ˋ;
    private RelativeLayout ͺ;
    private boolean ॱॱ = false;
    private TextView ᐝ;

    public ImmersiveHeadImgCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        azb.ॱ(view, j.ˋᶫ);
        this.ˋ = (RenderImageView) view.findViewById(j.ˋᴵ);
        this.ᐝ = (TextView) view.findViewById(j.ˋﹶ);
        this.ʻ = (TextView) view.findViewById(j.ˌʼ);
        this.ʼ = (TextView) view.findViewById(j.ˋⁱ);
        this.ͺ = (RelativeLayout) view.findViewById(j.ˌʻ);
        azb.ॱ(this.ʼ);
        this.ˋ.setListener(this);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        ImmersiveHeadImgCardBean immersiveHeadImgCardBean = (ImmersiveHeadImgCardBean) cardBean;
        if (!this.ˊॱ) {
            int ˎ = epv.ˎ(this.ˊˋ.getContext());
            float f = 1.25f;
            if (immersiveHeadImgCardBean.ॱ() == 8) {
                f = 0.5625f;
            }
            int i = (int) (f * ((float) ˎ));
            LayoutParams layoutParams = (LayoutParams) this.ͺ.getLayoutParams();
            layoutParams.width = ˎ;
            layoutParams.height = i;
            this.ͺ.setLayoutParams(layoutParams);
            this.ˊॱ = true;
        }
        if (immersiveHeadImgCardBean.ʽ() != null) {
            this.ᐝ.setText(immersiveHeadImgCardBean.ʽ());
        }
        if (immersiveHeadImgCardBean.ꜟ() != null) {
            this.ʻ.setText(immersiveHeadImgCardBean.ꜟ());
        }
        if (immersiveHeadImgCardBean.ᶥ() != null) {
            this.ʼ.setVisibility(0);
            this.ʼ.setText(immersiveHeadImgCardBean.ᶥ());
        }
        this.ʽ = immersiveHeadImgCardBean.ꜞ();
        eqx.ˎ(this.ˋ, immersiveHeadImgCardBean.ˊ(), "image_default_icon", this, true);
    }

    public void ॱ(Bitmap bitmap) {
        if (bitmap != null) {
            try {
                int ॱ = erq.ॱ(this.ʽ, bitmap);
                this.ˋ.setRenderColor(ॱ);
                this.ˋ.setRenderScale(0.3f);
                if (!this.ॱॱ) {
                    CustomActionBar.ˎ(this.ˋ.getContext(), ॱ, this.ˋ.getHeight());
                    boolean ˏ = erq.ˏ(ॱ);
                    ॱ = -16777216;
                    this.ʻ.setAlpha(azb.ˋ(this.ʼॱ, d.ߺ));
                    if (ˏ) {
                        ॱ = -1;
                        this.ʻ.setAlpha(azb.ˋ(this.ʼॱ, d.ॱʿ));
                    }
                    this.ᐝ.setTextColor(ॱ);
                    this.ʻ.setTextColor(ॱ);
                    this.ॱॱ = false;
                }
            } catch (IllegalStateException e) {
                Logger.e("ImmersiveHeadImgCard", e.toString());
            }
        }
    }

    public boolean ˋ(CSSDeclaration cSSDeclaration) {
        CSSValue propertyValue = cSSDeclaration.getPropertyValue(CSSPropertyName.FONT_COLOR);
        if (propertyValue != null && (propertyValue instanceof CSSMonoColor)) {
            this.ॱॱ = true;
        }
        return false;
    }
}
